package cn.itcast.utils;

import lombok.extern.slf4j.Slf4j;

/**
 * create by zhangtian on 2018/6/6
 */
@Slf4j
public class CodeMsg {
    private int code;
    private String msg;

    // 用户校验错误码
    public static final CodeMsg USER_UNIQUE_SUCCESS = new CodeMsg(100000, "用户名唯一") ;
    public static final CodeMsg USER_UNIQUE_USERNAME = new CodeMsg(100001, "用户名已存在") ;
    public static final CodeMsg USER_UNIQUE_IDCARDNO = new CodeMsg(100002, "身份证号已存在") ;

    private CodeMsg() {}

    private CodeMsg(int code, String msg ) {
        this.code = code;
        this.msg = msg;
    }

    public CodeMsg fillArgs(Object... args) {
        int code = this.code;
        String message = String.format(this.msg, args);
        return new CodeMsg(code, message);
    }

    public int getCode() {
        return code;
    }

    public void setCode(int code) {
        this.code = code;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }
}
